package com.dcits.idea.action;

import com.dcits.idea.data.DataCenter;
import com.dcits.idea.dialog.AddNoteDialog;
import com.dcits.idea.dialog.OpenDialog;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.SelectionModel;

public class AddToMK extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent e) {
        System.out.println("添加MK笔记");
        Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
        SelectionModel selectionModel = editor.getSelectionModel();

        DataCenter.CURRENT_FILE_NAME = e.getRequiredData(CommonDataKeys.PSI_FILE).getViewProvider().getVirtualFile().getName();
        DataCenter.CURRENT_FILE_TYPE = DataCenter.CURRENT_FILE_NAME.substring(DataCenter.CURRENT_FILE_NAME.lastIndexOf(".")+1);
        DataCenter.SELECTED_TEXT=selectionModel.getSelectedText();
        AddNoteDialog addNoteDialog = new AddNoteDialog();
        addNoteDialog.show();
    }
}
